package com.whc;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Stack;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by Administrator on 2022/2/10.
 */
public class Test {

    /**
     * ()()   (()))
     * @param str
     * @return
     */
    public static boolean checkValid(String str) {
        Stack<Character> stack = new Stack<Character>();
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == ')') {
                if (stack.isEmpty()) {
                    return false;
                }
                Character temp = stack.pop();
                if (temp == '(') {
                    continue;
                } else {
                    return false;
                }
            } else {
                stack.add(str.charAt(i));
            }
        }
        if (stack.isEmpty()) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        /*System.out.print(checkValid("((("));*/
        PrintAB r1 = new PrintAB(0, "A");
        PrintAB r2 = new PrintAB(1, "B");

        Thread thread1 = new Thread(r1);
        Thread thread2 = new Thread(r2);

        thread1.start();
        thread2.start();

        Map<Character, Integer> map = new HashMap<Character, Integer>();

    }
}
